package com.dlc.commonlibrary.ble;

import android.bluetooth.BluetoothDevice;
import android.util.Log;
import com.dlc.commonlibrary.R;

public class ClassScanner {
    private int device_icon;
    private String device_name;
    private String device_mac;
    private int device_type;
    private BluetoothDevice device;


    public ClassScanner(int device_icon, int device_type, BluetoothDevice device) {
        super();
        boolean debug = false;
        this.device_icon = device_icon;
        this.device_name = device.getName();
        this.device_mac = device.getAddress();
        this.device_type = device_type;
        this.device = device;

        if (debug) {
            Log.d("dsm362", Integer.toString(this.device_icon));
            Log.d("dsm362", this.device_name);
            Log.d("dsm362", this.device_mac);
            Log.d("dsm362", Integer.toString(this.device_type));
        }
    }


    public int getIcon() {
        return this.device_icon;
    }

    public String getName() {
        return this.device_name;
    }

    public String getMac() {
        return this.device_mac;
    }

    public int getType() {
        return this.device_type;
    }

    public BluetoothDevice getDevice() {
        return this.device;
    }

    public boolean getConnected() {
        if (this.device_type == R.drawable.ic_action_bluetooth_connected) return true;
        else return false;
    }


    public void setConnected() {
        this.device_type = R.drawable.ic_action_bluetooth_connected;
    }

    public void setDisConnected(String last_addr) {

        if (this.device_type == R.drawable.ic_action_bluetooth_connected) {

            if (last_addr.equals(device_mac))
                this.device_type = R.drawable.ic_action_save;
            else
                this.device_type = R.drawable.ic_action_bluetooth;
        }
    }
}
